package com.jyw.business.ast.controller;

import java.util.List;

import com.jyw.business.ast.domain.dto.web.AstDisposeDto;
import com.jyw.business.ast.domain.dto.web.AstDisposePageDto;
import com.jyw.business.ast.domain.dto.web.AstRejectedDto;
import com.jyw.business.ast.domain.vo.web.AstDisposeDetailVo;
import com.jyw.business.ast.domain.vo.web.AstDisposePageVo;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.core.page.BasePage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jyw.common.annotation.Log;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.enums.BusinessType;
import com.jyw.business.ast.service.IAstDisposeService;
import com.jyw.common.core.page.TableDataInfo;

/**
 * 资产-处置信息Controller
 * 
 * @author system
 * @date 2023-10-19
 */
@RestController
@RequestMapping("/ast/dispose")
@Api(tags = "资产处置")
public class AstDisposeController extends BaseController
{
    @Autowired
    private IAstDisposeService astDisposeService;

    /**
     * 查询资产-处置信息列表
     */
    @PreAuthorize("@ss.hasPermi('ast:dispose:list')")
    @PostMapping("/list")
    @ApiOperation("分页查询")
    public TableDataInfo<AstDisposePageVo> list(BasePage page, @RequestBody AstDisposePageDto dto)
    {
        startPage();
        List<AstDisposePageVo> list = astDisposeService.disposePage(dto);
        return getDataTable(list);
    }


    /**
     * 获取资产-处置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ast:dispose:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("处置详情")
    public CommonResult<AstDisposeDetailVo> getInfo(@PathVariable("id") Long id)
    {
        return CommonResult.success(astDisposeService.disposeDetail(id));
    }

    /**
     * 新增资产-处置信息
     */
    @PreAuthorize("@ss.hasPermi('ast:dispose:add')")
    @Log(title = "资产-处置信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("处置申请")
    public CommonResult add(@RequestBody AstDisposeDto dto)
    {
        astDisposeService.dispose(dto);
        return CommonResult.success();
    }


    /**
     * 删除资产-处置信息
     */
    @PreAuthorize("@ss.hasPermi('ast:dispose:revoke')")
    @Log(title = "资产-处置信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    @ApiOperation("撤销")
    public CommonResult revoke(@PathVariable Long id)
    {
        astDisposeService.revoke(id);
        return CommonResult.success();
    }

    @PreAuthorize("@ss.hasPermi('ast:dispose:audit:list')")
    @PostMapping("audit/list")
    @ApiOperation("审批管理-分页查询")
    public TableDataInfo<AstDisposePageVo> page(BasePage page,@RequestBody AstDisposePageDto dto)
    {
        startPage();
        List<AstDisposePageVo> list = astDisposeService.auditDisposePage(dto);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('ast:dispose:audit:pass')")
    @PutMapping("audit/pass")
    @ApiOperation("审批管理-通过")
    public CommonResult page(@RequestBody List<Long> list)
    {
        astDisposeService.pass(list);
        return CommonResult.success();
    }

    @PreAuthorize("@ss.hasPermi('ast:dispose:audit:reject')")
    @PutMapping("audit/reject")
    @ApiOperation("审批管理-驳回")
    public CommonResult reject(@RequestBody AstRejectedDto dto)
    {
        astDisposeService.reject(dto);
        return CommonResult.success();
    }


}
